﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace DiveManager
{
    public partial class FinanzEinstellungen : Form
    {
        private bool mandant_set;
        private string report_object;
        private string mandant_status;
        
        protected DiveDatabaseEntities diveDatabase;
        
        public FinanzEinstellungen()
        {
            InitializeComponent();

            // Init Database
            diveDatabase = new DiveDatabaseEntities();
        }

        private void btChangeMandant_Click(object sender, EventArgs e)
        {
            //Ändern des Mandanten
            //Versuch der änderung in Reportrting schreiben
            //Schreiben in Reporting
            ReportingMain report = new ReportingMain();
            report.ID = System.Guid.NewGuid();
            report.Report_Text = "Mandantenänderung -> Versuch";
            report.Sortierung = 3000;
            report.Objekt = report_object;
            // Add to DB
            diveDatabase.AddToReportingMain(report);
            diveDatabase.SaveChanges();

            
        }

        private void FinanzEinstellungen_Load(object sender, EventArgs e)
        {
            //Abfrage in Mandant
            var query_mandant = from m in diveDatabase.Mandant
                                select m;

            foreach (var m in query_mandant)
            {
                txFirma.Text = m.Firma;
                txStrasse.Text = m.Straße;
                txHSNR.Text = m.HSNR;
                txPLZ.Text = m.PLZ.ToString();
                txOrt.Text = m.Ort;
                txMandant.Text = m.Mandant_Nr.ToString();
            }

            if (txFirma.Text.Equals(""))
            {
                //mandant_Set = false
                mandant_set = false;
                report_object = "Default-Master PW";
            }
            else
            {
                //mandant_set=true
                mandant_set = true;
                report_object = "Owners-Master PW";
            }

        }
    }
}
